package TrafficSim;

import javax.vecmath.Vector2d;

public class TrafficLightSensor {

	private Street street;
	private Vector2d direction;

	public TrafficLightSensor(Street street, Vector2d direction) {
		this.direction = direction;
		this.street = street;
	}

	public int getAmountOfVehicles() {
		return street.getVehicles().size();
	}

	public int getInactiveVehicles() {
		int counter = 0;
		for (Vehicle vehicle : street.getVehicles()) {
			if (vehicle.getDirection() == this.direction
					&& vehicle.getSpeed().length() == 0) {
				counter++;
			}
		}
		return counter;
	}

	public int getActiveVehicles() {
		int counter = 0;
		for (Vehicle vehicle : street.getVehicles()) {
			if (vehicle.getDirection() == this.direction
					&& vehicle.getSpeed().length() != 0) {
				counter++;
			}
		}
		return counter;
	}

}
